<template>
  <view class="content">
    <div class="main">
      <p>您好，小程序需要您的授权才能更好的为您服务</p>
      <p>获取你的公开信息（昵称，头像，手机号等）</p>
      <div>
        <span @click="off">取消</span>
        <span @click="ok">确定</span>
      </div>
    </div>
  </view>
</template>

<script>
import {logins} from '@/service/index'
export default {
  data() {
    return {};
  },
  onLoad() {},
  onShow() {},
  methods: {
    ok() {
      wx.login({
				success: async res=>{
					let result = await logins(res.code);
					wx.setStorageSync('openid', result.data.openid);
				}
			})
      wx.switchTab({
        url: "/pages/home/index"
      });
    },
    off() {
      wx.reLaunch({
        url: "/pages/login/index"
      });
    }
  }
};
</script>

<style scoped lang="scss">
.main {
  position: fixed;
  top: 50%;
  left: 50%;
  margin-left: -300rpx;
  margin-top: -300rpx;
  border-radius: 20rpx;
  box-shadow: 1px 1px 4px 2px #888888;
  width: 600rpx;
  height: 400rpx;
  p:nth-child(1) {
    width: 90%;
    margin: 0 auto;
    text-align: center;
    margin-top: 60rpx;
  }
  p:nth-child(2) {
    width: 80%;
    margin: 0 auto;
    font-size: 24rpx;
    margin-top: 30rpx;
  }
  div {
    width: 80%;
    margin: 0 auto;
    margin-top: 50rpx;
    display: flex;
    justify-content: space-between;
    span:nth-child(1) {
      border: 1px solid #ddd;
      height: 70rpx;
      border-radius: 70rpx;
      line-height: 70rpx;
      width: 45%;
      text-align: center;
    }
    span:nth-child(2) {
      background-color: rgb(236, 48, 105);
      height: 70rpx;
      line-height: 70rpx;
      border-radius: 70rpx;
      width: 45%;
      text-align: center;
      color: #fff;
    }
  }
}
</style>
